package org.xb.SimpleProxy;

/**
 * @Author
 * @Description
 * @Date created in 11:08 2023/12/7
 */
// 代理类
class ImageProxy implements Image {
    private RealImage realImage;
    private String filename;

    public ImageProxy(String filename) {
        this.filename = filename;
    }

    @Override
    public void display() {
        // 在显示图像之前，检查是否已经创建了实际的图像对象
        if (realImage == null) {
            realImage = new RealImage(filename);
        }
        realImage.display();
    }
}
